﻿package mortal.game.view.tianDiRank.panel
{
    import com.mui.controls.*;
    import com.mui.display.*;
    import extend.language.*;
    import mortal.common.global.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.map3D.*;
    import mortal.game.view.common.*;
    import mortal.game.view.copy.*;
    import mortal.game.view.tianDiRank.data.*;
    import mortal.game.view.tianDiRank.item.*;

    public class TianDiInfoPanel extends CopyInfoPanelBase
    {
        protected var _bg:ScaleBitmap;
        protected var _nameBg:ScaleBitmap;
        protected var _title:GTextFiled;
        protected var _tip:GTextFiled;
        protected var _posName:GTextFiled;
        protected var _attrList:CellsGridSprite;
        protected var _leftTimeDes:GTextFiled;
        protected var _leftTimeTxt:GTextFiled;
        protected var _splitLine:GBitmap;
        protected var _openBtn:GLoadedButton;
        private var _seT:SecTimerView;
        private var _pos:int = -1;
        private static var _instance:TianDiInfoPanel;

        public function TianDiInfoPanel()
        {
            super("", 255);
            this.layer = LayerManager.uiLayer;
            this.mouseEnabled = true;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bg = UIFactory.bg(1, 2, 253, 267, this._bodySprite, ImagesConst.TaskTrack_Bg);
            this._nameBg = UIFactory.bg(28, 85, 205, 25, this._bodySprite, ImagesConst.PetNameBg);
            this._title = UIFactory.gTextField("", 98, 29, 100, 25, this._bodySprite, GlobalStyle.textFormatHuang2.setSize(15).setBold(true));
            this._tip = UIFactory.gTextField("" + Language.getString(71963), 5, 54, 254, 25, this._bodySprite, GlobalStyle.textFormatHuang2.setSize(13).center().setBold(true));
            this._posName = UIFactory.gTextField("", 10, 85, 250, 30, this._bodySprite, GlobalStyle.textFormatHuang2.setSize(15).center());
            this._attrList = UIFactory.getUICompoment(CellsGridSprite);
            this._attrList.colNum = 1;
            this._attrList.vCellWid = 100;
            this._attrList.hCellWid = 22;
            this._attrList.genCellFun = UIFactory.getUICompoment;
            this._attrList.genCells(5, TianDiPosCell);
            this._attrList.x = 87;
            this._attrList.y = 118;
            this._bodySprite.addChild(this._attrList);
            this._leftTimeDes = UIFactory.gTextField("" + Language.getString(71964), 46, 228, 100, 20, this._bodySprite, GlobalStyle.textFormatHuang2.setSize(13));
            this._leftTimeTxt = UIFactory.gTextField("", 145, 228, 100, 20, this._bodySprite, GlobalStyle.textFormatLv.setSize(13));
            this._splitLine = UIFactory.gBitmap(ImagesConst.SplitLine, 26, 79, this._bodySprite);
            _moveBtn.move(34, 31);
            _btnUnExpand.move(211, 30);
            this._seT = UIFactory.secTimeView("mm:ss");
            this._seT.addEventListener(EventName.SecViewTimeChange, this.onTimeChange);
            this._openBtn = UIFactory.gLoadedButton(ImagesConst.DownButton_upSkin, 211, 30, 18, 18);
            this._openBtn.visible = false;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._bg = null;
            this._nameBg = null;
            this._title = null;
            this._tip = null;
            this._posName = null;
            this._attrList = null;
            this._leftTimeDes = null;
            this._leftTimeTxt = null;
            this._splitLine = null;
            this._seT.dispose();
            this._seT = null;
            this._pos = -1;
            return;
        }// end function

        public function updateCopyPos(param1:int) : void
        {
            this._pos = param1;
            return;
        }// end function

        public function updateUpdateInfo() : void
        {
            if (this._pos == -1)
            {
                return;
            }
            this._title.text = Language.getStringByParam(71965, TianDiRankUtil.getTypeName());
            var _loc_1:* = TianDiRankUtil.getCopyCfgByPos(this._pos);
            this._posName.text = Language.getString(71966) + _loc_1.jobName;
            this.updateAtt(_loc_1.titleId);
            return;
        }// end function

        private function updateAtt(param1:int) : void
        {
            var _loc_4:TianDiPosCell = null;
            var _loc_5:Object = null;
            var _loc_2:* = TianDiRankUtil.getTitleAttr(param1);
            this._attrList.genCells(_loc_2.length, TianDiPosCell);
            var _loc_3:int = 0;
            while (_loc_3 < _loc_2.length)
            {
                
                _loc_4 = this._attrList.cellArr[_loc_3];
                _loc_5 = _loc_2[_loc_3];
                _loc_4.updateInfo(_loc_5["attrName"], _loc_5["attrValue"]);
                _loc_3++;
            }
            return;
        }// end function

        public function updateCopyTime(param1:int) : void
        {
            this._seT.setLeftTime(param1);
            return;
        }// end function

        private function onTimeChange(event:DataEvent) : void
        {
            if (this._seT == null)
            {
                return;
            }
            if (this._seT.secTimerViewData == null)
            {
                this._seT.stop();
                return;
            }
            var _loc_2:* = this._seT.secTimerViewData.mm();
            var _loc_3:* = this._seT.secTimerViewData.ss();
            _loc_2 = _loc_2.length < 2 ? ("0" + _loc_2) : ("" + _loc_2);
            _loc_3 = _loc_3.length < 2 ? ("0" + _loc_3) : ("" + _loc_3);
            this._leftTimeTxt.text = Language.getStringByParam(71967, _loc_2, _loc_3);
            return;
        }// end function

        override public function show(param1:int = 0, param2:int = 0) : void
        {
            super.show(param1, param2);
            this.stageResize();
            return;
        }// end function

        override public function stageResize() : void
        {
            super.stageResize();
            x = SceneRange.display.width - 226 - 30;
            y = 200;
            return;
        }// end function

        public static function get instance() : TianDiInfoPanel
        {
            if (_instance == null)
            {
                _instance = new TianDiInfoPanel;
            }
            return _instance;
        }// end function

        public static function hasInstance() : Boolean
        {
            return _instance != null;
        }// end function

    }
}
